package com.xyx.mapper;


import com.xyx.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    //1.查询
    @Select("select * from user ")
    List<User> findAll();
    //2.姓名模糊查询
    @Select("SELECT * FROM user WHERE name LIKE CONCAT('%', #{name}, '%')")
    List<User> findByNameLike(String name);
    //3
    @Update("UPDATE user SET name=#{name}, age=#{age} WHERE id=#{id}")
    int updateById(User user);
    //4
    @Insert("INSERT INTO User(name, age) VALUES(#{name}, #{age})")
    @Options(useGeneratedKeys=true, keyProperty="id")
    void insert(User user);
    //5
    @Delete("DELETE FROM user WHERE id=#{id}")
    int deleteById(Integer id);
}
